home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C & C++ Multimedia Cyber Classroom
/
C and C++ Multimedia Cyber Classroom (Prentice Hall) (1998).iso
/
src
/
fig09_11.jar
/
Ch09
/
Fig09_11
/
Derived.cpp
< prev
next >
Wrap
C/C++ Source or Header
|
1997-10-26
|
730b
|
25 lines
// Fig. 9.11: derived.cpp
// Member function definitions for class Derived
#include <iostream.h>
#include "derived.h"
// Constructor for Derived calls constructors for
// class Base1 and class Base2.
// Use member initializers to call base-class constructors
Derived::Derived( int i, char c, double f )
: Base1( i ), Base2( c ), real ( f ) { }
// Return the value of real
double Derived::getReal() const { return real; }
// Display all the data members of Derived
ostream &operator<<( ostream &output, const Derived &d )
{
output << " Integer: " << d.value
<< "\n Character: " << d.letter
<< "\nReal number: " << d.real;
return output; // enables cascaded calls
}